// source --> http://www.racer-piscine.com/wp-content/plugins/advanced-iframe/js/ai.js?ver=378675 /** * Advanced iframe pro functions v2020.4 */ /* jslint devel: true, unused: false */ /* globals ai_show_id_only:false, aiIsIe8: false, aiChangeUrl: false, aiResizeIframeHeightId: false, aiShowIframeId: false, findAndReplaceDOMText: false */ var aiEnableCookie=false; var aiId=''; var aiExtraSpace = 0; var aiAccTime = 0; var aiOnloadEventsCounter = 0; var aiCallbackExists = typeof aiReadyCallbacks !== 'undefined' && aiReadyCallbacks instanceof Array; var aiReadyCallbacks = aiCallbackExists ? aiReadyCallbacks : []; /** * This function resizes the iframe after loading to the height * of then content of the iframe. * * The extra space is not stored in the cookie! The height would * be added every time otherwise and the iframe would grow, */ function aiResizeIframe(obj, resizeWidth, resizeMinHeight) { try { if (obj.contentWindow.location.href === 'about:blank') { return; } if (obj.contentWindow.document.body != null) { var oldScrollposition = jQuery(window).scrollTop(); obj.style.marginTop = 0; obj.style.marginBottom = 0; obj.height = Number(resizeMinHeight); // set to 1 because otherwise the iframe does never get smaller. obj.style.height = Number(resizeMinHeight) + 'px'; var newheight = aiGetIframeHeight(obj); obj.height = newheight; obj.style.height = newheight + 'px'; // set the height of the zoom div if (jQuery('#ai-zoom-div-' + obj.id).length !== 0) { var zoom = window['zoom_' + obj.id]; jQuery('#ai-zoom-div-' + obj.id).css('height', newheight * zoom); } if (aiEnableCookie && aiExtraSpace === 0 ) { aiWriteCookie(newheight); } var hash = aiGetIframeHash(obj.contentWindow.location.href); if (hash !== -1) { var iframeId = '#'+ obj.id; try { var hashposition = jQuery(iframeId).contents().find('#'+ hash); if (hashposition.length !== 0) { var hashpositionTop = hashposition.offset().top; oldScrollposition = Math.round(jQuery(iframeId).offset().top + hashpositionTop); } } catch(e) { // in case of an invalid hash it is ignored. } } setTimeout(function() { jQuery("html,body").scrollTop(oldScrollposition); }, 50); if (resizeWidth === 'true') { var newWidth = aiGetIframeWidth(obj); obj.width = newWidth; obj.style.width = newWidth + 'px'; } var fCallback = window['resizeCallback' + obj.id]; fCallback(); // fires the onload event again if iframes are wrapped if (window.frameElement != null) { parent.jQuery('iframe').trigger('onload'); } } else { // body is not loaded yet - we wait 100 ms. setTimeout(function() { aiResizeIframe(obj, resizeWidth); },100); } } catch(e) { if (console && console.log) { console.log('Advanced iframe configuration error: You have enabled the resize of the iframe for pages on the same domain. But you use an iframe page on a different domain. You need to use the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); console.log(e); } } } /** * returns the position of a #hash in the iframe or -1 if none was found. */ function aiGetIframeHash(url) { var hash = url.split('#')[1]; return (hash) ? hash : '-1'; } /** * Get the iframe height */ function aiGetIframeHeight(obj) { var bodyHeight = Math.max(obj.contentWindow.document.body.scrollHeight, obj.contentWindow.document.body.offsetHeight, obj.contentWindow.document.documentElement.scrollHeight, obj.contentWindow.document.documentElement.offsetHeight); var newheight = bodyHeight + aiExtraSpace; return newheight; } /** * Get the iframe width */ function aiGetIframeWidth(obj) { var oldWidth = obj.width; obj.width = 1; // set to 1 because otherwise I don't get the minimum width obj.style.width = '1px'; var bodyWidth = Math.max(obj.contentWindow.document.body.scrollWidth, obj.contentWindow.document.body.offsetWidth, obj.contentWindow.document.documentElement.scrollWidth, obj.contentWindow.document.documentElement.offsetWidth); if (bodyWidth !== 1) { // avoid that fully responsive sites do not get displayed at all. obj.width = bodyWidth; obj.style.width = bodyWidth + 'px'; } else { obj.width = oldWidth; obj.style.width = oldWidth + 'px'; } return bodyWidth; } /** * Get the current width of the iframe inside the parent. */ function aiGetParentIframeWidth(obj) { if (obj != null && jQuery('#' + obj.id).length !== 0) { return jQuery('#' + obj.id).width(); } else { return -1; } } /** * Resizes an iframe to a given height. * this is used for xss enabled iframes. * Please read the documentation! */ function aiResizeIframeHeightById(id, nHeight) { try { var fCallback = window['resizeCallback' + id]; fCallback(); var height = parseInt(nHeight,10) + aiExtraSpace; var iframe = document.getElementById(id); var oldScrollposition = jQuery(document).scrollTop(); iframe.height = height; iframe.style.height = height + 'px'; jQuery("html,body").scrollTop(oldScrollposition); if (aiEnableCookie && aiExtraSpace === 0) { aiWriteCookie(height); } // send the new height to the parent if it is a wrapped call var parentResizeCall = window['aiExecuteWorkaround_' + id]; if (parentResizeCall != null) { parentResizeCall(); } } catch(e) { if (console && console.log) { console.log('Advanced iframe configuration error: The id of the parent and the external workaround are different! Check your settings.'); console.log(e); } } } /** * Scrolls the parent window to the top. * This is e.g. wanted when you have a link in the iframe and you want that the * page starts at the top and not that only the iframe changes. * * Sometimes are 2 onload events after another. To prevent that this causes * a jump to the top a delay of 1 sec is used for the increase of the counter. */ function aiScrollToTop(id, position) { if (aiOnloadEventsCounter > 0) { var posTop = 0; if (position === 'iframe') { posTop = jQuery('#' + id).offset().top; } setTimeout(function() { window.scrollTo(0, posTop); }, 100); } setTimeout(function() { aiOnloadEventsCounter++; }, 1000); } /** * Writes the last height to the cookie. */ function aiWriteCookie(height) { var cookieName = 'ai-last-height'; if (aiId !== '') { cookieName = cookieName + '-' + aiId ; } var cookieStr = cookieName + '=' + height; document.cookie=cookieStr; } /** * Reads the cookie and preset the height of the iframe */ function aiUseCookie() { var cookieName = 'ai-last-height'; if (aiId !== '') { cookieName = cookieName + '-' + aiId ; } var allcookies = document.cookie; // Get all the cookies pairs in an array var cookiearray = allcookies.split(';'); // Now take key value pair out of this array for (var i = 0; i < cookiearray.length; i++) { var name = cookiearray[i].split('=')[0]; var value = cookiearray[i].split('=')[1]; // cookie does exist and has a numeric value if (name === cookieName && value !== null && aiIsNumeric(value)) { var iframe = document.getElementById(aiId); iframe.height = parseInt(value,10); iframe.style.height = value + 'px'; } } } /** * check if we have a numeric input */ function aiIsNumeric(input){ return !isNaN(input); } /** * Disable the additional_height input field */ function aiDisableHeight() { jQuery('#additional_height').attr('readonly','readonly'); jQuery('#additional_height').val('0'); } /** * Enable the additional_height input field */ function aiEnableHeight() { jQuery('#additional_height').removeAttr('readonly'); } /** * Removes all elements from an iframe except the given one * * @param iframeId id of the iframe * @param showElement the id, class (jQuery syntax) of the element that should be displayed. */ function aiShowElementOnly( iframeId, showElement ) { try { var iframe = jQuery(iframeId).contents().find('body'); var selectedBox = iframe.find(showElement).clone(true,true); iframe.find('*').not(jQuery('script')).remove(); iframe.prepend(selectedBox); } catch(e) { if (console && console.log) { console.log('Advanced iframe configuration error: You have enabled to show only one element of the iframe for pages on the same domain. But you use an iframe page on a different domain. You need to use the pro version of the external workaround like described in the settings. Also check the next log. There the browser message for this error is displayed.'); console.log(e); } } } function aiCheckIfValidTarget(evt, elements) { var targ; if (!evt) { evt = window.event; } if (evt.target) { targ = evt.target; } else if (evt.srcElement) { targ = evt.srcElement; } if (targ.nodeType === 3) { targ = targ.parentNode; } var parts = elements.split(','); // check each part if we have a match... for (var i=0; i< parts.length; ++i) { var selectorArray = parts[i].split(':'); if (selectorArray[0].toLowerCase() === targ.nodeName.toLowerCase()) { if (selectorArray.length > 1) { if (targ.id.toLowerCase().indexOf(selectorArray[1].toLowerCase()) !== -1) { return true; } } else { return true; } } } return false; } function aiOpenSelectorWindow (url) { var localWidth = jQuery('#width').val(); var localHeight = jQuery('#ai-height-0').val(); if (localWidth.indexOf('%') >= 0 || Number(localWidth) < 900) { localWidth = 900; } localWidth = Number(localWidth) + 40; if ( localWidth > (screen.width)) { localWidth = screen.width; } if (localHeight.indexOf('%') >= 0) { localHeight = screen.height; } else { localHeight = Number(localHeight) + 480; } if ( localHeight > (screen.height-50)) { localHeight = screen.height-50; } var options = 'width='+localWidth+',height='+localHeight+',left=0,top=0,resizable=1,scrollbars=1'; var popup_window = window.open(url, '', options); popup_window.focus(); } function aiDisableAiResizeOptions(value) { jQuery('#onload_resize_delay').prop('readonly',value); jQuery('input[id=store_height_in_cookie1]:radio, input[id=store_height_in_cookie2]:radio').attr('disabled',value); jQuery('#additional_height').prop('readonly', value); jQuery('input[id=onload_resize_width1]:radio, input[id=onload_resize_width2]:radio').attr('disabled',value); jQuery('#resize_on_click').prop('readonly', value); jQuery('#resize_on_click_elements').prop('readonly', value); jQuery('#resize_on_ajax').prop('readonly', value); jQuery('input[id=resize_on_ajax_jquery1]:radio, input[id=resize_on_ajax_jquery2]:radio').attr('disabled',value); var selector = '#onload_resize_delay, #store_height_in_cookie1, #additional_height, #onload_resize_width1, '; selector += '#resize_on_click, #resize_on_click_elements, #resize_on_ajax, #resize_on_ajax_jquery1'; aiDisableTextSection(value, selector); } function aiDisablePartOfIframeOptions(value) { jQuery('#show_part_of_iframe_x').prop('readonly',value); jQuery('#show_part_of_iframe_y').prop('readonly',value); jQuery('#show_part_of_iframe_height').prop('readonly',value); jQuery('#show_part_of_iframe_width').prop('readonly',value); jQuery('input[id=show_part_of_iframe_allow_scrollbar_horizontal1]:radio, input[id=show_part_of_iframe_allow_scrollbar_horizontal2]:radio').attr('disabled',value); jQuery('input[id=show_part_of_iframe_allow_scrollbar_vertical1]:radio, input[id=show_part_of_iframe_allow_scrollbar_vertical2]:radio').attr('disabled',value); jQuery('#show_part_of_iframe_next_viewports').prop('readonly',value); jQuery('input[id=show_part_of_iframe_next_viewports_loop1]:radio, input[id=show_part_of_iframe_next_viewports_loop2]:radio').attr('disabled',value); jQuery('#show_part_of_iframe_new_window').prop('readonly',value); jQuery('#show_part_of_iframe_new_url').prop('readonly',value); jQuery('input[id=show_part_of_iframe_next_viewports_hide1]:radio, input[id=show_part_of_iframe_next_viewports_hide2]:radio').attr('disabled',value); jQuery('#show_part_of_iframe_style').prop('readonly',value); jQuery('input[id=show_part_of_iframe_zoom1]:radio, input[id=show_part_of_iframe_zoom2]:radio, input[id=show_part_of_iframe_zoom3]:radio').attr('disabled',value); jQuery('.media-query-input').prop('readonly',value); var selector = '#show_part_of_iframe_x, #show_part_of_iframe_y, #show_part_of_iframe_height, #show_part_of_iframe_width, '; selector += '#show_part_of_iframe_allow_scrollbar_horizontal1, #show_part_of_iframe_next_viewports, #show_part_of_iframe_next_viewports_loop1, '; selector += '#show_part_of_iframe_new_window, #show_part_of_iframe_new_url, #show_part_of_iframe_next_viewports_hide1, #show_part_of_iframe_style, '; selector += '#show_part_of_iframe_zoom1, #show_part_of_iframe_allow_scrollbar_vertical1, #add-media-query-show_part_of_iframe_media_query'; aiDisableTextSection(value, selector); if (value) { jQuery('#add-media-query-show_part_of_iframe_media_query').hide(); jQuery('.ai-delete').hide(); } else { jQuery('#add-media-query-show_part_of_iframe_media_query').show(); jQuery('.ai-delete').show(); } } function aiDisableLazyLoadOptions(value) { jQuery('#enable_lazy_load_threshold').prop('readonly', value); jQuery('#enable_lazy_load_fadetime').prop('readonly', value); jQuery('input[id=enable_lazy_load_reserve_space1]:radio, input[id=enable_lazy_load_reserve_space2]:radio').attr('disabled',value); jQuery('input[id=enable_lazy_load_manual1]:radio, input[id=enable_lazy_load_manual2]:radio, input[id=enable_lazy_load_manual3]:radio').attr('disabled',value); var selector = '#enable_lazy_load_threshold, #enable_lazy_load_fadetime, #enable_lazy_load_reserve_space1, #enable_lazy_load_manual1'; aiDisableTextSection(value, selector); } function aiDisableIframeAsLayerOptions(value) { jQuery('input[id=show_iframe_as_layer_full]:radio').attr('disabled',value); jQuery('#show_iframe_as_layer_header_file').prop('readonly', value); jQuery('#show_iframe_as_layer_header_height').prop('readonly', value); jQuery('input[id=show_iframe_as_layer_header_position1]:radio, input[id=show_iframe_as_layer_header_position2]:radio').attr('disabled',value); jQuery('input[id=show_iframe_as_layer_full1]:radio, input[id=show_iframe_as_layer_full2]:radio, input[id=show_iframe_as_layer_full3]:radio').attr('disabled',value); jQuery('input[id=show_iframe_as_layer_keep_content1]:radio, input[id=show_iframe_as_layer_keep_content2]:radio').attr('disabled',value); var selector = '#show_iframe_as_layer_full, #show_iframe_as_layer_header_file, #show_iframe_as_layer_header_height, '; selector += '#show_iframe_as_layer_header_position1, #show_iframe_as_layer_full1, #show_iframe_as_layer_keep_content1'; aiDisableTextSection(value, selector); } function aiDisableTextSection(value, selector) { if (value) { jQuery(selector).closest('tr').addClass('disabled'); } else { jQuery(selector).closest('tr').removeClass('disabled'); } } var aiInstance; /** * This function initializes all checks that are done by Javascript * on the admin page like enabling disabling fields... */ function aiInitAdminConfiguration(isPro, acc_type) { // enable checkbox of onload_resize_delay and if resize is set to true external workaround is set to false if (jQuery('input[type=radio][name=onload_resize]:checked').val() === 'false') { aiDisableAiResizeOptions(true); } jQuery('input[type=radio][name=onload_resize]').click( function(){ if (jQuery(this).val() === 'true') { jQuery('input:radio[name=enable_external_height_workaround]')[1].checked = true; // set to external! aiDisableAiResizeOptions(false); } else { jQuery('#onload_resize_delay').val(''); aiDisableAiResizeOptions(true); } }); // if external workaround is set to to true resize on load is set to false and the // onload_resize_delay is made readonly jQuery('input[type=radio][name=enable_external_height_workaround]').click( function(){ if (jQuery(this).val() === 'true') { jQuery('input:radio[name=onload_resize]')[1].checked = true; jQuery('#onload_resize_delay').val(''); aiDisableAiResizeOptions(true); } }); // Show only a part of the iframe enable/disable if (jQuery('input[type=radio][name=show_part_of_iframe]:checked').val() === 'false') { aiDisablePartOfIframeOptions(true); } jQuery('input[type=radio][name=show_part_of_iframe]').click( function(){ if (jQuery(this).val() === 'false') { aiDisablePartOfIframeOptions(true); } else { aiDisablePartOfIframeOptions(false); } }); // show_iframe_as_layer enable/disable if (jQuery('input[type=radio][name=show_iframe_as_layer]:checked').val() === 'false') { aiDisableIframeAsLayerOptions(true); } jQuery('input[type=radio][name=show_iframe_as_layer]').click( function(){ if (jQuery(this).val() === 'false') { aiDisableIframeAsLayerOptions(true); } else { aiDisableIframeAsLayerOptions(false); } }); // if expert mode if (jQuery('input[type=radio][name=expert_mode]:checked').val() === 'true') { jQuery('.description').css('display','none'); jQuery('table.form-table th').css('cursor','pointer'); jQuery('table.form-table th').css('padding-top','8px').css('padding-bottom','2px'); jQuery('table.form-table td').css('padding-top','5px').css('padding-bottom','5px'); jQuery('table.form-table th').click(function() { jQuery('.description').css('display','none'); jQuery('.description', jQuery(this).parent()).css('display','block'); }); } jQuery('input[type=radio][name=expert_mode]').click( function(){ if (jQuery(this).val() === 'false') { jQuery('.description').css('display','block'); jQuery('table.form-table th').css('cursor','auto'); jQuery('table.form-table th').off('click'); jQuery('table.form-table th').css('padding-top','20px').css('padding-bottom','20px'); jQuery('table.form-table td').css('padding-top','15px').css('padding-bottom','15px'); } else { jQuery('.description').css('display','none'); jQuery('table.form-table th').css('cursor','pointer'); jQuery('table.form-table th').css('padding-top','8px').css('padding-bottom','2px'); jQuery('table.form-table td').css('padding-top','5px').css('padding-bottom','5px'); jQuery('table.form-table th').click(function() { jQuery('.description').css('display','none'); jQuery('.description', jQuery(this).parent()).css('display','block'); }); } }); jQuery('#accordion').find('h1').click(function(){ jQuery(this).next().slideToggle(aiAccTime); }).next().hide(); jQuery('#accordion').find('a').click(function(){ var hash = jQuery(this).prop('hash'); var hash_only = '#h1-' + hash.substring(1); jQuery(hash_only).next().show(); location.hash = hash_only; }); // lazy load if (jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val() === 'false') { jQuery('#enable_lazy_load_manual_element').prop('readonly',true); } jQuery('input[type=radio][name=enable_lazy_load_manual]').click( function(){ if (jQuery(this).val() === 'false' || jQuery(this).val() === 'auto') { jQuery('#enable_lazy_load_manual_element').prop('readonly',true); } else { jQuery('#enable_lazy_load_manual_element').prop('readonly',false); } }); if (jQuery('input[type=radio][name=enable_lazy_load]:checked').val() === 'false') { aiDisableLazyLoadOptions(true); jQuery('#enable_lazy_load_manual_element').prop('readonly',true); } jQuery('input[type=radio][name=enable_lazy_load]').click( function(){ if (jQuery(this).val() === 'false') { aiDisableLazyLoadOptions(true); jQuery('#enable_lazy_load_manual_element').prop('readonly',true); } else { aiDisableLazyLoadOptions(false); if (jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val() === 'false' || jQuery('input[type=radio][name=enable_lazy_load_manual]:checked').val() === 'auto' ) { jQuery('#enable_lazy_load_manual_element').prop('readonly',true); } else { jQuery('#enable_lazy_load_manual_element').prop('readonly', false); } } }); jQuery('.confirmation').on('click', function () { return confirm('Are you sure? Selecting OK will set all settings to the default.'); }); jQuery('a.post').click(function(e) { e.stopPropagation(); e.preventDefault(); var href = this.href; var parts = href.split('?'); var url = parts[0]; var params = parts[1].split('&'); var pp, inputs = ''; url += '?' + params[0]; for(var i = 1, n = params.length; i < n; i++) { pp = params[i].split('='); inputs += ''; } jQuery('body').append('
'); jQuery('#poster').submit(); }); jQuery('.ai-input-search').keyup(function(e) { var searchTerm = jQuery('input.ai-input-search').val().toLowerCase(); aiSettingsSearch(searchTerm, acc_type); }); jQuery('.ai-input-search').on('click', function(e) { setTimeout(function() { var searchTerm = jQuery('input.ai-input-search').val().toLowerCase(); aiSettingsSearch(searchTerm, acc_type); }, 100); }); jQuery(document).on( 'click', '.nav-tab-wrapper a', function() { var current_tab = jQuery(this).attr('id'); jQuery('section').hide(); jQuery('section.' + current_tab ).show(); jQuery('#current_tab').val(current_tab.substr(4,1)); jQuery('.nav-tab').removeClass('nav-tab-active'); jQuery(this).addClass('nav-tab-active'); jQuery(this).blur(); return false; }); // set the links between tabs and open the right one at the right section. jQuery(document).on( 'click', 'a#external-workaround-link', function() { jQuery('.external-workaround').click(); location.hash = 'tab_3'; // no flash aiShowHeader('tab_3'); return false; }); jQuery(document).on( 'click', 'a#resize-same-link', function() { jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-resize').removeClass('closed'); location.hash = 'id-advanced-resize'; // no flash aiShowHeader('id-advanced-resize'); return false; }); jQuery(document).on( 'click', 'a.jquery-help-link', function() { jQuery('.help-tab').click(); jQuery('#id-help-jquery').removeClass('closed'); jQuery('#jquery-help').show(); location.hash = 'id-help-jquery'; // no flash aiShowHeader('id-help-jquery'); return false; }); jQuery(document).on( 'click', 'a#browser-detection-link', function() { jQuery('.help-tab').click(); jQuery('#id-help-browser').removeClass('closed'); jQuery('#browser-help').show(); location.hash = 'id-help-browser'; // no flash aiShowHeader('id-help-browser'); return false; }); jQuery(document).on( 'click', 'a.howto-id-link', function() { jQuery('.help-tab').click(); jQuery('#id-help-id').removeClass('closed'); location.hash = 'id-help-id'; // no flash aiShowHeader('id-help-id'); return false; }); jQuery(document).on( 'click', '.modifycontent-link', function() { jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-modify-iframe').removeClass('closed'); location.hash = 'id-advanced-modify-iframe'; aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); return false; }); jQuery(document).on( 'click', '.id-modify-css-iframe-link', function() { jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-modify-iframe').removeClass('closed'); location.hash = 'id-modify-css-iframe'; aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); return false; }); jQuery(document).on( 'click', '.modify-target', function() { jQuery('.advanced-settings-tab').click(); jQuery('#id-advanced-modify-iframe').removeClass('closed'); location.hash = 'id-modify-target'; aiShowHeader('id-advanced-modify-iframe', 'tr-' + jQuery(this).data('detail')); return false; }); jQuery(document).on( 'click', 'a.link-external-domain', function() { jQuery('#id-external-different').removeClass('closed'); location.hash = '#id-external-different'; // no flash - 'id-external-different' aiShowHeader('id-external-different'); return false; }); jQuery(document).on( 'click', 'a.link-id-external-ai-config-post', function() { jQuery('#id-external-ai-config-post').removeClass('closed'); location.hash = '#id-external-ai-config-post'; aiShowHeader('id-external-ai-config-post', 'tr-use_post_message'); return false; }); jQuery(document).on( 'click', 'a.link-id-external-ai-overview', function() { jQuery('#id-external-ai-overview').removeClass('closed'); location.hash = '#id-external-ai-overview'; aiShowHeader('id-external-ai-overview', 'id-external-ai-overview'); return false; }); jQuery(document).on( 'click', 'a.post-message-help-link', function() { jQuery('.help-tab').click(); jQuery('#id-help-communication').removeClass('closed'); location.hash = '#id-help-communication'; aiShowHeader('id-help-communication','id-help-communication'); return false; }); jQuery(document).on( 'click', 'a.enable-admin', function() { jQuery('.options-tab').click(); jQuery('#id-options-display').removeClass('closed'); location.hash = '#id-options-display'; aiShowHeader('id-options-display', 'tr-demo'); return false; }); jQuery(document).on( 'click', 'a#user-help-link', function() { jQuery('#user-help').css('display', 'block'); return false; }); jQuery(document).on( 'click', 'a#user-meta-link', function() { jQuery('#meta-help').css('display', 'block'); return false; }); jQuery(document).on( 'click', '#ai-selector-help-link', function() { jQuery('#ai-selector-help').slideDown(1000); return false; }); jQuery(document).on( 'click', '.ai-selector-help-link-move', function() { jQuery('#ai-selector-help').show('slow'); location.hash = '#ai-selector-help-link'; // no flash aiShowHeader('ai-selector-help-link'); return false; }); jQuery('#ai_form').submit(function() { aiSetScrollposition(); }); // Close postboxes that should be closed. jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); // Postboxes setup. if (typeof postboxes !== 'undefined') { postboxes.add_postbox_toggles('toplevel_page_advanced-iframe'); } jQuery('.ai-spinner').css('display','none'); jQuery("#" + acc_type).next().show(); jQuery(document).on( 'click', '#test-pro-admin.is-permanent-closable button', function() { closeInfoPermanent('test-pro-admin'); }); jQuery(document).on( 'click', '.mq-breakpoint-height a', function(evt) { jQuery(this).parent().remove(); aiUpdateHeightHiddenField('height'); evt.preventDefault(); return false; }); jQuery(document).on( 'click', 'a#add-media-query-height', function(evt) { // count existing elements var nextNr = jQuery(".mq-breakpoint-height").length + 1; jQuery(this).parent().append('r: ' + debugData + '
'); } } function aiProcessScrollToTop(jsObject) { var id = jsObject.id; aiScrollToTop(id, aiOnloadScrollTop); } function aiProcessHeight(jsObject) { var nHeight = jsObject.height; var nWidth = jsObject.width; var iAnchor = parseInt(jsObject.anchor,10); var id = jsObject.id; if (nHeight != null) { try { var loc = jsObject.loc; if (loc != null) { aiChangeUrl(loc); } if (id != null) { var iHeight = parseInt(nHeight,10); var iWidth = parseInt(nWidth,10); aiResizeIframeHeightId(iHeight,iWidth, id); if (!isNaN(iAnchor) && iAnchor > -1) { // var iframeTop = jQuery("#" + id).offset().top; setTimeout(function() { jQuery("html,body").scrollTop(Math.round(iframeTop + iAnchor)); aiShowIframeId(id); }, 100); } else { aiShowIframeId(id); } } else { alert('Please update the ai_external.js to the current version.'); } } catch(e) { if (console && console.log) { console.log(e); } } } } function aiProcessShow(jsObject) { var id = jsObject.id; try { aiShowIframeId(id); } catch(e) { if (console && console.log) { console.log(e); } } } function aiRemoveElementsFromHeight(id,height,removeElements) { var iframe = jQuery('#' + id); var elementArray = removeElements.split(','); var totalHeight = 0; for (var i = 0; i < elementArray.length; i++) { try { var el = elementArray[i]; if (el.includes("|")) { var rangeArray = el.split('|'); var bottomElement = jQuery(rangeArray[0]); var beforeBottom = Math.round(bottomElement.offset().top + bottomElement.outerHeight(true)); var nextTop = Math.round(jQuery(rangeArray[1]).offset().top); totalHeight += nextTop - beforeBottom; } else if (el === 'top') { totalHeight += Math.round(jQuery('#' + id).offset().top); } else if (isNaN(el)) { totalHeight += jQuery(el).outerHeight(true); } else { totalHeight += parseInt(el); } } catch(e) { if (console && console.log) { console.log('Advanced iframe configuration error: The configuration of remove_elements_from_height "'+removeElements+'" is invalid. Please check if the elements you defined do exist and ids/classes are defined properly.'); console.log(e); } } } var calc = 'calc(' + height + ' - ' + totalHeight + 'px)'; iframe.css('height', calc); } // IE11 does not support includes if (!String.prototype.includes) { String.prototype.includes = function(search, start) { if (typeof start !== 'number') { start = 0; } if (start + search.length > this.length) { return false; } else { return this.indexOf(search, start) !== -1; } }; };